package com.imooc;


import cn.hutool.core.util.NumberUtil;
import com.imooc.job.MyJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

public class QuartzDemo {
    public static void main(String[] args) throws SchedulerException, InterruptedException {
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        scheduler.start();


        int[] ints = NumberUtil.generateRandomNumber(1, 100, 1);


        JobDetail jobDetail = JobBuilder.newJob(MyJob.class)
                //jobdetail的标识
                .withIdentity("jobDetail", "group1")
                .usingJobData("name", "Jack")
                .usingJobData("count", ints[0])
                .build();


        Trigger trigger = TriggerBuilder.newTrigger()
                .withSchedule(CronScheduleBuilder.cronSchedule("3/5 * * * * ?")
                )
                .build();

        scheduler.scheduleJob(jobDetail, trigger);

        Thread.sleep(5000);

        scheduler.shutdown();

    }
}
